<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;


class Blog extends Model
{
    //自定义表名
    protected $table = "blog";
    //时间戳
    public $timestamps = false;
    //Create属性
    protected $fillable = ['title','content'];
    //增加博客
    public static function add($arr)
    {
        //判断输入的标题和内容是否为空
    	  if(!empty($arr ->title) && !empty($arr->content)){
             
            return Blog::create(['title'=>$arr->title,'content'=>$arr->content]);
           //return true;
        }
    }
    //更新博客
    public static function upda($arr,$id)
    {
        //判断更新的标题和内容
    	if(!empty($arr->title) && !empty($arr->content)){
			$data = Blog::where('id',$id)->update(["title"=>$arr->title,"content"=>$arr->content]);
			if($data){
				return true;
			}else{
				return false;
			}
    	}else{
    		return false;
    	}
    	
    }
 }